layui.config({
	base : "js/"
}).use(['form','layer','jquery','layedit','laydate'],function(){
	var form = layui.form,
		layer = parent.layer === undefined ? layui.layer : parent.layer,
		$ = layui.jquery;

 	form.on("submit(addNews)",function(data){
 		var datas=data.field;
 		var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
 		$.ajax({  
            type: "POST",  
            url:"/users/add",
            data:JSON.stringify(datas),// 序列化表单值
            contentType:"application/json",
            success: function(data) {
            	if(data.code==200){
            		top.layer.close(index);
           			layer.closeAll("iframe");
          	 		parent.location.reload();
            	}
            	layer.msg(data.msg);
            } ,
 		
	 		 error: function(data) {
	             alert(data);
	         } 
        });
 		return false;
 	})
	
})
